<?php
/**
 * 批量发送邮件
 * 读文件中的邮件,存在数组里了,用163的邮件发送
 * 
 * 发送用的是163的服务器,会有限制，所以每个邮件可以发20次，每封发40个地址
 */
//exit("处理好");
include_once "send_email_function.php";
set_time_limit(0);
ini_set('date.timezone', "Asia/Shanghai");
$s8 = microtime(true);

$host_email_address = array(
	array("Host"=>"smtp.163.com","userNmae"=>"asdf23r2w@163.c​om","pwd"=>"asf34turty45","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"itylw_com_cn@163.c​om","pwd"=>"121as34f434f","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"q3admin_c_abc@163.c​om","pwd"=>"asdf2rf23f2","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"asdwf434t3g@163.c​om","pwd"=>"4r23r23r23d","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"xcvwewev2323@163.c​om","pwd"=>"zxcvwfwgwgeg","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"fvb34t3434@163.c​om","pwd"=>"sdf3r23r23","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"asdfxcw3434334@163.c​om","pwd"=>"sdfr234r23r23","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"xwsh34@163.c​om","pwd"=>"sdww42342w","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"xswsh34@163.c​om","pwd"=>"xdwer52323","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"sre334xswsh34@163.c​om","pwd"=>"svet34t3tdf","displayName"=>"周五粉"),
	array("Host"=>"smtp.163.com","userNmae"=>"sdsd23r42323@163.c​om","pwd"=>"sdsd23r42323wef","displayName"=>"周五粉"),
	//array("Host"=>"smtp.163.com","userNmae"=>"aaaaaaaa@163.c​om","pwd"=>"bbbbbb","displayName"=>"周五粉"),
	
	//qq邮箱
	array("Host"=>"smtp.qq.com","userNmae"=>"2684603965@qq.com","pwd"=>"6s5df5s5d5s6sd55d5","displayName"=>"周五粉"),
	array("Host"=>"smtp.qq.com","userNmae"=>"2647992425@qq.com","pwd"=>"peng123456","displayName"=>"周五粉"),
	array("Host"=>"smtp.qq.com","userNmae"=>"2632164105@qq.com","pwd"=>"1234567890","displayName"=>"周五粉"),
	array("Host"=>"smtp.qq.com","userNmae"=>"1413180202@qq.com","pwd"=>"1234567890","displayName"=>"周五粉"),
	//array("Host"=>"smtp.qq.com","userNmae"=>"aaaaaaaa@qq.com","pwd"=>"bbbbbb","displayName"=>"周五粉"),
);
$host_email_address_count = count($host_email_address);

$success = 0;$faile = 0;
$sum_send = 0;//共发送多少封

$fp = fopen("status_".date("Ymd_H_i_s").".txt", "a");//将当前的状态写入文件
//取得要发送的邮件地址
$email_all_array = include_once "data/data_22_zhijide.php";
//$email_all_array = include_once "data/data_22_zhijide.php";
foreach($email_all_array as $email){
	$sum_send++;
	//每个邮件的标题都不一样
	$title = "全方位_大空间_展示图片_".rand(100000,999999)."_".$email;
	$keyEmail = ($sum_send%$host_email_address_count);
	$flage = send_email_function($host_email_address[$keyEmail],array($email),$title,getBody($email));//发送邮件
	
	$end8 = date("Y-m-d H:i:s");
	//echo $flage;exit;
	if($flage){
		$success++;
	}else{
		$faile++;
		sleep(1);
	}
	if($sum_send%1 == 0){
		//每发100封记一次日志
		fwrite($fp, "成功:{$success},失败:{$faile},时间:{$end8},{$email}");//写入日志
		sleep(2);
	}
}
fwrite($fp, "成功:{$success},失败:{$faile},时间:{$end8},{$email}");//写入日志
echo "success:".$success."faile:".$faile;
echo "<br>time:".number_format(microtime(true) - $s8, 3, '.', '')."s";
